/*
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

#include <IRremote.h>

int LED_PIN = 13;
int RECV_PIN = 6;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  // Setup Serial connection
  Serial.begin(9600);
  
  // Start the IR Receiver
  irrecv.enableIRIn();

  // Setup LED pin
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  if (irrecv.decode(&results)) {
    
    // Turn on the onboard LED on receive
    digitalWrite(LED_PIN, HIGH);    
    
    // Report the received value to serial
    Serial.println(results.value, HEX);
    
    // Listen for next value
    irrecv.resume();
  }
  else {
    
    // Turn off LED if we're waiting
    digitalWrite(LED_PIN, LOW);
  
  }
}
